package com.qf.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.pojo.DtsRole;
import com.qf.service.RoleService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.management.relation.Role;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * projectName: wokepase1
 *
 * @author: 强力
 * time: 2021/9/14 14:25
 * description:角色管理接口
 */
@RestController
@RequestMapping("/role")
@CrossOrigin("*")
public class RoleController {

    @Autowired
    private RoleService roleService;
    @RequestMapping("/options")
    public Object option(){

        List<DtsRole> roles=roleService.findAll();


        List<Map<String,Object>> resultList=new ArrayList<>();

        if (roles != null) {
            for (DtsRole role : roles) {
                Map<String,Object> data=new HashMap<>();
                data.put("value",role.getId());
                data.put("label",role.getName());
                resultList.add(data);
            }
        }


        return ResponseUtil.ok(resultList);
    }
}
